﻿#pragma once


#include <memory>
#include "Containers/WeakObjectPtr.h"
#include "PixelObjectID.h"
#include "Math/Coordinate.h"

class RSceneComponent;

enum class EPixelObjectType
{
    Unknown,
    Component,
    Axis,

    //自定义的像素对象
    Custom
};

//像素对应的对象
class WHENGINE_API CPixelObject
{
public:
    EPixelObjectType ObjectType=EPixelObjectType::Unknown;
};

//像素对应的组件
class WHENGINE_API CComponentPixelObject : public CPixelObject
{
public:
    CComponentPixelObject()
    {
        ObjectType=EPixelObjectType::Component;
    }

    TWeakObjectPtr<RSceneComponent> SceneComponent;
};

//像素对应的坐标轴
class WHENGINE_API CAxisPixelObject : public CPixelObject
{
public:


    CAxisPixelObject(EAxis InAxisType)
    {
        ObjectType=EPixelObjectType::Axis;
        AxisType=InAxisType;
    }

    EAxis AxisType=EAxis::X;
};

//所有的像素对象，用于查询
struct WHENGINE_API SPixelObjects
{

public:
    
    //清空
    void Reset()
    {
        Objects.Clear(false);
    }

    //注册一个像素对象，返回对应的像素值
    SPixelObjectID Register(std::shared_ptr<CPixelObject> InObject)
    {
        Objects.Add(InObject);
        return Objects.Num() - 1;
    }

    //获取像素对象
    std::shared_ptr<CPixelObject> GetObject(SPixelObjectID InID)
    {
        if(InID>=Objects.Num())
        {
            return nullptr;
        }
        return Objects[InID];
    }
protected:
    //索引为像素值
    TVector<std::shared_ptr<CPixelObject>> Objects;
};
